package com.tarena.lbs.attach.schedule;

import com.tarena.lbs.attach.service.FileService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 清理过期文件的定时任务
 * 每天自动检查并删除过期的文件
 */
@Component
public class CleanExpiredFilesJob {

    private final FileService fileService;

    public CleanExpiredFilesJob(FileService fileService) {
        this.fileService = fileService;
    }

    @Scheduled(cron = "0 0 2 * * ?") // 每天凌晨2点执行
    public void cleanExpiredFiles() {
        fileService.cleanExpiredFiles();
    }
}
